<template>
    <div class="head">
      <div class="head_cont">
        <!---logo+搜索---->
        <div class="main_cer clearfix">
          <div class="head_right fr" style="margin-right:8px;margin-top:28px;">
             <ul class="clearfix">
              <li v-for="item in partList">
                <a :href="item.href" target="_blank">{{item.label}}</a>
              </li>
             </ul>
             <div class="search_head clearfix">
                <input v-model="s_input" placeholder="" class="fl" />
                <div class="btn fr" @click="searchCont">
                  <i class="iconfont icon-sousuo"></i>
                </div>
             </div>
          </div>
        </div>
      </div>
      <!-----导航------>
      <div class="menu " >
        <ul class="clearfix">
          <li v-for="(item,index) in columns" :key="index" :class="[index == hindex ? 'on' : '']">
            <!-- <i :class="item.style"></i>
            <span v-html="item.label"></span>  -->
             <!-- {{ item.label }} -->
            <!-- v-if="item.catid" -->
            <a v-if="item.catid" :href="item.href + '?catid=' + item.catid" target="_blank">
              <i :class="item.style"></i>
              <span v-html="item.label"></span>
            </a>
            <a v-if="item.href && !item.catid" :href="item.href" target="_blank">
              <i :class="item.style"></i>
              <span v-html="item.label"></span>
            </a>
            <a v-if="!item.href && !item.catid" @click="goMenu(item)">
              <i :class="item.style"></i>
              <span v-html="item.label"></span>
            </a>
          </li>
        </ul>
      </div>
    </div>
</template>  
<script setup name="headIndex">
import { getMenu } from "@/api/yxzx/menu";
import { listpassInfo } from "@/api/yxzx/info"; 
export default {
    props: {
      hindex: {
          type: Number,
          required: true
      },
    },
    data() {
      return {
        leftUrl: 'http://192.168.9.250', //政工网
        loading: true,
        s_input: '',
        status: 0,
        // 列信息
        columns: [
          { key: 0, label: '首<span>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp</span>页', href: '/home' },
          { key: 1, label: `医院动态`, href: '/list',catid: '' },
          { key: 2, label: `通知公告`, href: '/list',catid: '' },
          { key: 3, label: `领导讲话`, href: '/list',catid: '' },
          { key: 4, label: `政策法规`}, // href: '/list',catid: '' 
          { key: 5, label: `军内要闻`, href: '/list',catid: '' },
          { key: 6, label: `精武强能`, href: '/list',catid: '' },
          { key: 7, label: `医教研讯`, href: '/list',catid: '' },
          // { key: 8, label: `东总周会`, href: '/list',catid: '' },
          { key: 8, label: `东总周会`},
          { key: 9, label: `医院号码查询`,href:'http://192.168.9.250/department/yyhmcx/index'},// 政工网
          { key: 10, label: `网上办公`,href:'http://192.168.9.250/oa/manage/login'},// // 政工网
          // { key: 9, label: `医院号码查询`,href:'http://26.19.192.90/department/yyhmcx/index'}, // jun网
          // { key: 10, label: `网上办公`}, // jun网
          // { key: 9, label: `医院号码查询`,href:'http://192.168.2.250/department/yyhmcx/index'}, // Hoa网
          // { key: 10, label: `网上办公`, href:'http://192.168.6.66'}, // Hoa网
          { key: 11, label: `时政论坛`, href: '/list',catid: '' },
          { key: 12, label: `视频新闻`, href: '/list',catid: '' },
          { key: 13, label: `院务保障`},
          { key: 14, label: `考评平台`},
          { key: 15, label: `表扬激励`, href: '/list',catid: '' },
          { key: 16, label: `纪实评价` },
          { key: 17, label: `基层风采`, href: '/list',catid: '' },
          { key: 18, label: `心得驿站`, href: '/list',catid: ''},
          { key: 19, label: `院长政委信箱`, href:'http://192.168.9.250/newguestbook/ask' },// 政工网
          // { key: 19, label: `院长政委信箱`, href:'http://26.19.192.90/newguestbook/ask' },// jun网
          //  { key: 19, label: `院长政委信箱`, href:'http://192.168.2.250/newguestbook/ask' },// Hoa网
        ],
        partList: [ //政工网
          { key: 0, label: `卫勤部`, href: 'http://192.168.9.250/homepage/wqb'},
          { key: 1, label: `政治工作部`, href: 'http://192.168.9.250/homepage/zgb' },
          { key: 2, label: `保障部`, href: 'http://192.168.9.250/department/bzb/index'},
          { key: 3, label: `护理部`, href: 'http://192.168.9.250/department/hltd/index'}
        ],
        partList2: [ // HOA
          { key: 0, label: `卫勤部`, href: 'http://192.168.2.250/homepage/wqb'},
          { key: 1, label: `政治工作部`, href: 'http://192.168.2.250/homepage/zgb' },
          { key: 2, label: `保障部`, href: 'http://192.168.2.250/department/bzb/index'},
          { key: 3, label: `护理部`, href: 'http://192.168.2.250/department/hltd/index'}
        ],
        partList3: [ // jun
          { key: 0, label: `卫勤部`, href: 'http://26.19.192.90/homepage/wqb'},
          { key: 1, label: `政治工作部`, href: 'http://26.19.192.90/homepage/zgb' },
          { key: 2, label: `保障部`, href: 'http://26.19.192.90/department/bzb/index'},
          { key: 3, label: `护理部`, href: 'http://26.19.192.90/department/hltd/index'}
        ]
      }
    },
    created() {
      this.getList()
      this.status = this.hindex
    },
    methods: {
      goFour(val){
        // this.$alert('该功能正在开发中！', '提示', {
        //   confirmButtonText: '确定',
        //   callback: action => {              
        //   }
        // });
        let routeUrl = this.$router.resolve({
            path:val.href
        })  
        window.open(routeUrl.href, ' blank');
      },
      /** 查询菜单列表 */
      getList() {
        this.loading = true;
        getMenu().then(response => {
          this.$emit('getCat', response.resultContent)
          response.resultContent.map((item) => {
            if (item.categoryname == '医院动态') {
              this.columns[1].catid = item.categoryid
            } else if (item.categoryname == '通知公告') {
              this.columns[2].catid = item.categoryid
            } else if (item.categoryname == '领导讲话') {
              this.columns[3].catid = item.categoryid
            } else if (item.categoryname == '政策法规') {
              this.columns[4].catid = item.categoryid
            } else if (item.categoryname == '军内要闻') {
              this.columns[5].catid = item.categoryid
            } else if (item.categoryname == '精武强能') {
              this.columns[6].catid = item.categoryid
            } else if (item.categoryname == '医教研讯') {
              this.columns[7].catid = item.categoryid
            } else if (item.categoryname == '东总周会') {
              this.columns[8].catid = item.categoryid
            } else if (item.categoryname == '时政论坛') {
              this.columns[11].catid = item.categoryid
            } else if (item.categoryname == '视频新闻') {
              this.columns[12].catid = item.categoryid
            } else if (item.categoryname == '表扬激励') {
              this.columns[15].catid = item.categoryid
            } else if (item.categoryname == '基层风采') {
              this.columns[17].catid = item.categoryid
            } else if (item.categoryname == '心得驿站') {
              this.columns[18].catid = item.categoryid
            }
          })
          this.loading = false;
        })
      },
      // 搜索方法
      searchCont(){
        if(this.s_input == ''){
          this.$message.error('您未输入搜索内容！');
        } else {
          this.$router.push({
            path:'/search',
            query: {
              text: this.s_input
            }
          });
        }
      },
      //点击导航事件
      goMenu(val){
        console.log(val)
        if(val.href && val.catid){
          let routeUrl = this.$router.resolve({
            path:'/list',
            query:{catid:val.catid}
          })  
          window.open(routeUrl.href, ' blank');
        } else if(val.href && !val.catid) {
          let routeUrl = this.$router.resolve({
            path:val.href
          })  
          window.open(routeUrl.href, ' blank');
        } else if(!val.href && !val.catid) {
          this.$alert('该功能正在开发中！', '提示', {
            confirmButtonText: '确定',
            callback: action => {              
            }
          });
        }
      },
      // 收藏
      addFavorite() {
          var title = document.title;
          var URL = document.URL; 
          try { 
            window.external.addFavorite(URL, title);          //ie
          } catch(e) {
              console.log(e)
              try {
                  window.sidebar.addPanel(title, URL, "");     //firefox
              } catch(e) {
                  alert("加入收藏失败，请使用Ctrl+D进行添加");     //chrome opera safari
              }
          }
      },
      setHome(obj) {
          try {
              obj.style.behavior = 'url(#default#homepage)';
              obj.setHomePage('https://www.cacee.org.cn/');
          } catch (e) {
              if (window.netscape) {
                  try {
                      netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
                  } catch (e) {
                      alert("请在浏览器地址栏输入“about:config”并回车然后将[signed.applets.codebase_principal_support]设置为'true'");
                  };
                  var pre = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
　　　　　　　　    pre.setCharPref('browser.startup.homepage','https://www.cacee.org.cn/');
              } else {
                  alert("请手动将" + 'https://www.cacee.org.cn/' + "设置为首页。");
              };
          };
      },

    },
}
</script>